<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加表格中的行</title>
</head>

<body>
    <table id="myTable" border="1">
        <tr>
            <td>行1 列1</td>
            <td>行1 列2</td>
        </tr>
        <tr>
            <td>行2 列1</td>
            <td>行2列2</td>
        </tr>
        <tr>
            <td>行3 列1</td>
            <td>行3 列2</td>
        </tr>
    </table>
    <br>
    <input type="button" onclick="insRow()" value="插入行">
    <script>
        function insRow() {
            var x = document.getElementById('myTable').insertRow(0);
            var y = x.insertCell(0);
            var z = x.insertCell(1);
            y.innerHTML = "新单元格1";
            z.innerHTML = "新单元格2";
        }
    </script>
</body>

</html>